package com.baoyouqun.controller.union;

import com.zaxxer.hikari.HikariDataSource;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;

@RestController
public class PoolMonitorController {
    @Resource
    private DataSource dataSource;

    @GetMapping("/pool/status")
    public String getPoolStatus() {
        HikariDataSource hikariDataSource = (HikariDataSource) dataSource;
        //        status.append("活跃连接数: ").append(hikariDataSource.getActiveConnections()).append("\n");
//        status.append("空闲连接数: ").append(hikariDataSource.getIdleConnections()).append("\n");
//        status.append("等待连接数: ").append(hikariDataSource.getPendingConnections()).append("\n");
//        status.append("总连接数: ").append(hikariDataSource.getTotalConnections()).append("\n");
        return "";
    }
}